<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- <link rel="icon" href="../../favicon.ico"> -->

    <title>企业管理</title>

    <!-- Bootstrap core CSS -->
    <link href="./libs/bootstarp/css/bootstrap.min.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <!-- <link href="../../assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet"> -->

    <!-- Custom styles for this template -->
    <link href="./css/index.css" rel="stylesheet">
    <link rel="stylesheet" href="./css/enterprise.css">
    <link rel="stylesheet" href="./css/user.css">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <!-- <script src="../../assets/js/ie-emulation-modes-warning.js"></script> -->

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <!-- <script src="./libs//template/template-web.js"></script> -->
    <style>
        [v-cloak] {
            display: none !important;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <zdy-nav title="企业管理" :nav-list="navList"></zdy-nav>

        <div class="container zdy-container">
            <form class="form-horizontal user-form">
                <div class="row col-md-offset-2">
                    <div class="form-group col-md-8">
                        <label class="col-sm-3 control-label">公司logo</label>
                        <div class="col-sm-9">
                            <input type="file" style="display: none;" ref="file" @change="handleOnChange">
                            <img :src="picPath" width="100px" height="100px" alt="" @click="handleOnClickImg">
                        </div>
                    </div>
                    <div class="form-group col-md-8">
                        <label for="inputText1" class="col-sm-3 control-label">公司名称</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="inputText1" placeholder="请输入公司名称"
                                v-model="options.name">
                        </div>
                    </div>
                    <div class="form-group col-md-8">
                        <label for="inputText2" class="col-sm-3 control-label">公司规模</label>
                        <div class="col-sm-9">
                            <!-- <input type="number" class="form-control" id="inputText2" placeholder="请输入公司规模"
                                v-model="options.scale"> -->
                            <select class="form-control" v-model="options.scale" placeholder="请选择公司规模">
                                <option value="20人以下">20人以下</option>
                                <option value="20-50人">20-50人</option>
                                <option value="50-100人">50-100人</option>
                                <option value="100-300人">100-300人</option>
                                <option value="300以上">300以上</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group col-md-8">
                        <label for="inputText3" class="col-sm-3 control-label">公司地址</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="inputText3" placeholder="请输入公司地址"
                                v-model="options.address">
                        </div>
                    </div>
                    <div class="form-group col-md-8">
                        <label for="inputText1" class="col-sm-3 control-label">公司介绍</label>
                        <div class="col-sm-9">
                            <textarea class="form-control" rows="3" placeholder="请输入公司介绍"
                                v-model="options.info"></textarea>
                        </div>
                    </div>
                    <div class="form-group col-md-8">
                        <label for="inputText1" class="col-sm-3 control-label">备注信息</label>
                        <div class="col-sm-9">
                            <textarea class="form-control" rows="3" placeholder="请输入备注信息"
                                v-model="options.comment"></textarea>
                        </div>
                    </div>
                    <div class="form-group col-md-12 ">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button class="btn btn-primary" type="button" @click="handleOnClick">确定</button>
                            <button class="btn" type="button" @click="handleOnClose">取消</button>
                        </div>
                    </div>
                </div>
            </form>
        </div><!-- /.container -->

        <zdy-footer></zdy-footer>

    </div>

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> -->
    <!-- <script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script> -->
    <script src="./libs/jquery/jquery.min.js"></script>
    <script src="./libs/bootstarp/js/bootstrap.js"></script>
    <script src="./libs/vue/vue.js"></script>
    <script src="./tpl/publicTpl.js"></script>
    <script src="./js/utils.js"></script>
    <script src="./js/xhr.js"></script>

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <!-- <script src="../../assets/js/ie10-viewport-bug-workaround.js"></script> -->
    <script>
        var vm = new Vue({
            el: '#app',
            data() {
                return {
                    navList: [
                        { text: '首页', value: '0', path: './enterprise.html' },
                        { text: '简历库', value: '1', path: './resume.html' },
                        { text: '公司编辑', value: 'active', path: './editor.html' },
                        { text: '发布职位', value: '3', path: './addJob.html' }
                    ],
                    titleShow: true,
                    descShow: true,
                    options: {
                        compId: '',
                        logo: '',
                        name: '',
                        info: '',
                        scale: '',
                        address: '',
                        comment: ''
                    },
                    jobList: [],
                    jobs: [],
                    resumeList: [],
                    resumes: [],
                    url: '',
                    modalOptions: {}
                }
            },
            computed: {
                picPath() {
                    console.log(this.url)
                    return this.url.indexOf('null') > -1 ? './img/img_add.png' : this.url;
                    // return './img/img_add.png'
                },
                jobSize() {
                    return Math.ceil(this.jobList.length / 10);
                },
                resumeSize() {
                    return Math.ceil(this.resumeList.length / 10);
                }
            },
            created() {
                var self = this;
                var type = getSession('type');
                if (type == 0) {
                    window.location.replace('./index.html')
                }
                var comp = auth();
                if (comp) {
                    var param = {
                        compId: comp.id
                    }
                    xhr.send('/pub/iface/job/getComp', param, function (res) {
                        self.options = res.comp;
                        self.url = res.comp.logoName !== '' ? res.comp.logo : '';
                        self.options['compId'] = comp.id;
                        self.options['logo'] = res.comp.logoName || '';
                    })
                }
            },
            methods: {
                handleOnClose: function () {
                    window.history.back();
                },
                handleOnClick: function () {
                    var self = this;
                    xhr.send('/pub/iface/job/editComp', this.options, function (res) {
                        console.log(res)
                        if (res.code == 0) {
                            alert('更新公司信息成功')
                        } else {
                            alert(res.msg)
                        }
                    })
                },
                handleOnClickImg: function () {
                    this.$refs.file.click();
                },
                handleOnChange: function (event) {
                    var self = this;
                    var files = event.target.files[0];
                    var fd = new FormData();
                    fd.append('file', files);
                    xhr.upload('/pub/iface/job/upload', fd, function (res) {
                        self.options.logo = res.filename;
                        self.options.logoName = res.filename;
                        self.url = res.url;
                        // self.handleOnClick();
                    })
                }
            },
        })
    </script>
</body>

</html>